<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<style>
	div {width: 20px; height: 20px; background: purple; position: absolute;}	
</style>
<script>
	function getPos(ev)
	{
			var oEvent = ev || event;
			var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
			var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
		
			return {X: ev.clientX + scrollLeft, Y: ev.clientY + scrollTop}
	}
	
	window.onload = function()
	{
				document.onmousemove = function(ev)
				{
						var aDiv = document.getElementsByTagName('div');
						var oEvent = ev || event;
						var pos = getPos(oEvent);

						for(var i=aDiv.length-1 ; i > 0 ;i--)
						{
							aDiv[i].style.left= aDiv[i-1].offsetLeft + 'px';
							aDiv[i].style.top= aDiv[i-1].offsetTop + 'px';
						}
					
						aDiv[0].style.left = pos.X + 'px';
						aDiv[0].style.top = pos.Y + 'px';
		
				};
	};
	</script>
</head>

<body>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
